<?php

include("modules/members/global.php");

$pagetitle=" - Members";
$links=" > Members";

include("header.php");

if(!$mode){$mode="alpha";}

if($mode=="ida"||$mode=="idd"){

  for($n=0;$n<count($usersarray);$n++){
  $userarray=getdata("$configarray[1]/$usersarray[$n]/main.php");

  $idarray[$usersarray[$n]]=$usersarray[$n];
  }


 if($mode=="ida"){@asort($idarray);}
 if($mode=="idd"){@arsort($idarray);}
 $orderarray=@array_keys($idarray);

}

if($mode=="alpha"||$mode=="reversealpha"){

  for($n=0;$n<count($usersarray);$n++){

  $userarray=getdata("$configarray[1]/$usersarray[$n]/main.php");

  $username=$usersarray[$n];

  $displaynamearray["$username"]=$userarray[0];
  }


 if($mode=="alpha"){@asort($displaynamearray);}
 if($mode=="reversealpha"){@arsort($displaynamearray);}

 $orderarray=@array_keys($displaynamearray);

}

if($mode=="postsa"||$mode=="postsd"){

  //create array of post count from each user
  for($n=0;$n<count($usersarray);$n++){

  $userarray=getdata("$configarray[1]/$usersarray[$n]/main.php");

  $username=$usersarray[$n];

  $postcountarray["$username"]=$userarray[6];

  }

  if($mode=="postsa"){@asort($postcountarray);}
  if($mode=="postsd"){@arsort($postcountarray);}
  $orderarray=@array_keys($postcountarray);

}

if($mode=="rega"||$mode=="regd"){

  //create array of post count from each user

  for($n=0;$n<count($usersarray);$n++){

  $userarray=getdata("$configarray[1]/$usersarray[$n]/main.php");

  $userid=$usersarray[$n];

  $regarray["$userid"]=$userarray[4];

  }

  if($mode=="rega") {@asort($regarray);}
  if($mode=="regd") {@arsort($regarray);}

  $orderarray=array_keys($regarray);
}

unset($tplcontent);

if($mode=="ida"){
$tplcontent['idlink'].="<a href=\"modules.php?module=members&mode=idd\">".$languagedef['members'][0]." #</a>";
}else{
$tplcontent['idlink'].="<a href=\"modules.php?module=members&mode=ida\">".$languagedef['members'][0]." #</a>";
}


if($mode=="alpha"){
$tplcontent['namelink'].="<a href=\"modules.php?module=members&mode=reversealpha\">".$languagedef['members'][1]."</a>";
}else{
$tplcontent['namelink'].="<a href=\"modules.php?module=members&mode=alpha\">".$languagedef['members'][1]."</a>";
}

$tplcontent['emaillink'].=$languagedef['members'][7];

if($mode=="postsd"){
$tplcontent['postslink'].="<a href=\"modules.php?module=members&mode=postsa\">".$languagedef['members'][2]."</a>";
}else{
$tplcontent['postslink'].="<a href=\"modules.php?module=members&mode=postsd\">".$languagedef['members'][2]."</a>";
}

if($mode=="rega"){
$tplcontent['regdatelink'].="<a href=\"modules.php?module=members&mode=regd\">".$languagedef['members'][3]."</a>";
}else{
$tplcontent['regdatelink'].="<a href=\"modules.php?module=members&mode=rega\">".$languagedef['members'][3]."</a>";
}

$tplcontent['grouplink'].=$languagedef['members'][4];

if(!$page){$page=1;}

   for($n=($page-1)*$membersmoduleconfig[0];$n<count($orderarray)&&$n<(($page-1)*$membersmoduleconfig[0])+$membersmoduleconfig[0];$n++){
   $txtarray=getdata("$configarray[1]/$orderarray[$n]/main.php");
   
   unset($tplcontent2);

   $tplcontent2['id'].="$orderarray[$n]";

   $tplcontent2['name'].="<a href=\"profile.php?user=$orderarray[$n]\">$txtarray[0]</a>";

   $emailarray=explode("\t",$txtarray[2]);
   if($emailarray[1]=="hide")
   {
   $tplcontent2['email'].="$memberslanguage[6]";
   }else{
   $tplcontent2['email'].="$emailarray[0]";
   }

   $tplcontent2['posts'].="$txtarray[6]";

   $date=date($dateformat,$txtarray[4]+$timeoffsetseconds);
   $tplcontent2['regdate'].=$date;

   $tplcontent2['group'].="$txtarray[15]";
   
   $tplcontent['membersrows'].=template('modules/members/memberrow',$tplcontent2);

   }
   
  $tplcontent['pages'].=$languagedef['members'][5].": ";
  $page2=1;

  for($n=0;$n<count($orderarray);$n+=$membersmoduleconfig[0]){

   if($n==($page-1)*$membersmoduleconfig[0]) {
   $tplcontent['pages'].="<b>$page2</b> ";
   }else{
   $tplcontent['pages'].="<a href=\"modules.php?module=members&mode=$mode&page=$page2\">$page2</a> ";
   }

  $page2++;
  }
  
  echo template('modules/members/membersview',$tplcontent);

require ("footer.php");
?>
